<% layout('/layouts/default.html', {title: '故障通知单管理', libs: ['dataGrid']}){ %>
<div class="main-content">
	<div class="box box-main">
		<div class="box-header">
			<div class="box-title">
				<i class="fa fa-list-alt"></i> ${text('故障通知单管理')}
			</div>
			<div class="box-tools pull-right">
				<a href="#" class="btn btn-default" id="btnSearch" title="${text('查询')}"><i class="fa fa-filter"></i> ${text('查询')}</a>
				<% if(hasPermi('test:troubleNotice:edit')){ %>
					<a href="${ctx}/test/troubleNotice/form" class="btn btn-default btnTool" title="${text('新增故障通知单')}"><i class="fa fa-plus"></i> ${text('新增')}</a>
				<% } %>
			</div>
		</div>
		<div class="box-body">
			<#form:form id="searchForm" model="${troubleNotice}" action="${ctx}/test/troubleNotice/listData" method="post" class="form-inline hide"
					data-page-no="${parameter.pageNo}" data-page-size="${parameter.pageSize}" data-order-by="${parameter.orderBy}">
				<div class="form-group">
					<label class="control-label">${text('通知单类型')}：</label>
					<div class="control-inline width-120">
						<#form:select path="noticeType" dictType="notice_type" blankOption="true" maxlength="1" class="form-control"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('故障类型编号')}：</label>
					<div class="control-inline">
						<!--<最初考虑将该编号设置为点巡检异常编号，后考虑把事故异常编号也加进来，所以最终改为故障类型编号>-->
						<#form:input path="planCode" maxlength="64" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('设备编号')}：</label>
					<div class="control-inline">
						<#form:input path="equipCode" maxlength="64" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('维修人员编号')}：</label>
					<div class="control-inline">
						<#form:input path="maintainerCode" maxlength="64" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('故障类型')}：</label>
					<div class="control-inline width-120">
						<#form:select path="troubleType" dictType="trouble_type" blankOption="true" maxlength="1" class="form-control"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('故障内容')}：</label>
					<div class="control-inline">
						<#form:input path="troubleContent" maxlength="255" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('通知单状态')}：</label>
					<div class="control-inline width-120">
						<#form:select path="noticeStatus" dictType="notice_status" blankOption="true" maxlength="1" class="form-control"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('故障级别')}：</label>
					<div class="control-inline width-120">
						<#form:select path="troubleLevel" dictType="trouble_level" blankOption="true" maxlength="1" class="form-control"/>
					</div>
				</div>
				<!--<div class="form-group">-->
					<!--<label class="control-label">${text('状态')}：</label>-->
					<!--<div class="control-inline width-120">-->
						<!--<#form:select path="status" dictType="sys_search_status" blankOption="true" class="form-control"/>-->
					<!--</div>-->
				<!--</div>-->
				<!--<div class="form-group">-->
					<!--<label class="control-label">${text('备注信息')}：</label>-->
					<!--<div class="control-inline">-->
						<!--<#form:input path="remarks" maxlength="500" class="form-control width-120"/>-->
					<!--</div>-->
				<!--</div>-->
				<div class="form-group">
					<button type="submit" class="btn btn-primary btn-sm">${text('查询')}</button>
					<button type="reset" class="btn btn-default btn-sm">${text('重置')}</button>
				</div>
			</#form:form>
			<table id="dataGrid"></table>
			<div id="dataGridPage"></div>
		</div>
	</div>
</div>
<% } %>
<script>
// 初始化DataGrid对象
$('#dataGrid').dataGrid({
	searchForm: $("#searchForm"),
	columnModel: [
		{header:'${text('故障类型编号')}', name:'planCode', index:'a.plan_code', width:150, align:"left", frozen:true, formatter: function(val, obj, row, act){
			 if(row.troubleType == '0'){
				row.troubleType = "硬件";
            }else {
			   row.troubleType = "软件";
            }

            if(row.noticeStatus == '0'){
				row.noticeStatus = "待指派";
            }else if(row.noticeStatus == '1'){
				row.noticeStatus = "已指派，待承接";
            }else {
			   row.noticeStatus = "已承接";
            }

            if(row.troubleLevel== '0'){
				row.troubleLevel = "一般";
            }else if(row.troubleLevel == '1'){
				row.troubleLevel = "严重";
            }else {
			   row.troubleLevel = "非常严重";
            }
			if(row.noticeType == '0'){
				row.noticeType = "点检异常";
				<!--<点击点巡检计划编号，跳转到点巡检计划维护结果界面>-->
				return '<a href="${ctx}/test/checkPlans/list?planCode='+row.planCode+'"  target = "_blank" class="btnList" data-title="${text('编辑点检计划')}">'+(val||row.id)+'</a>';
            }else if(row.noticeType == '1'){
				row.noticeType = "巡检异常";
				 <!--<点击点巡检计划编号，跳转到点巡检计划维护结果界面>-->
				 return '<a href="${ctx}/test/inspectPlan/list?planCode='+row.planCode+'"  target = "_blank" class="btnList" data-title="${text('编辑巡检计划')}">'+(val||row.id)+'</a>';
            }else if(row.noticeType == '2'){
				row.noticeType = "预防性维护异常";
				 <!--<点击点预防性维护计划编号，跳转到点预防性维护计划结果界面>-->
				 return '<a href="${ctx}/test/preventMaintainPlan/list?planCode='+row.planCode+'"  target = "_blank" class="btnList" data-title="${text('编辑预防性维护计划')}">'+(val||row.id)+'</a>';
            }else {
			   row.noticeType = "事故";
			   return '<a href="${ctx}/test/troubleNotice/form?noticeCode='+row.noticeCode+'&planCode='+row.planCode+'" class="btnList" data-title="${text('编辑故障通知单')}">'+(val||row.id)+'</a>';
            }
            <!--<下面这种方式也是想实现根据通知单类型类跳转到相应的计划维护界面，但是前段都显示的是点检异常>-->
            <!--if(row.noticeType = "点检异常"){-->
            	<!--return '<a href="${ctx}/test/checkPlans/list?planCode='+row.planCode+'"  target = "_blank" class="btnList" data-title="${text('编辑点检计划')}">'+(val||row.id)+'</a>';-->
            <!--}else if(row.noticeType = "巡检异常"){-->
            	<!--return '<a href="${ctx}/test/inspectPlan/list?planCode='+row.planCode+'"  target = "_blank" class="btnList" data-title="${text('编辑巡检计划')}">'+(val||row.id)+'</a>';-->
            <!--}else{-->
              <!--<暂留，用于扩展事故>-->
            	<!--return '<a href="${ctx}/test/troubleNotice/form?noticeCode='+row.noticeCode+'&planCode='+row.planCode+'" class="btnList" data-title="${text('编辑故障通知单')}">'+(val||row.id)+'</a>';-->
            <!--}-->
		}},
		<!--{header:'${text('点巡检计划名称')}', name:'inspectPlan.treeName', index:'', width:150, align:"left", frozen:true, formatter:function(val, obj, row, act){-->
                <!--return '<a href="${ctx}/test/inspectPlan/list?inspectPlanCode='+row.inspectPlanCode+'"  target = "_blank" class="btnList" data-title="${text('编辑巡检安排')}">'+(val||row.id)+'</a>';-->
         <!--}},-->
		//{header:'${text('点巡检计划编号')}', name:'planCode', index:'a.plan_code', width:150, align:"left"},
		//{header:'${text('点巡检计划名称')}', name:'inspectPlan.treeName', index:'', width:150, align:"left"},
		{header:'${text('通知单类型')}', name:'noticeType', index:'a.notice_type', width:150, align:"left"},
		{header:'${text('设备编号')}', name:'equipCode', index:'a.equip_code', width:150, align:"left"},
		//{header:'${text('维修人员编号')}', name:'maintainerCode', index:'a.maintainer_code', width:150, align:"left"},
		{header:'${text('维修人员姓名')}', name:'user.userName', index:'', width:150, align:"left"},
		{header:'${text('故障类型')}', name:'troubleType', index:'a.trouble_type', width:150, align:"left"},
		{header:'${text('故障内容')}', name:'troubleContent', index:'a.trouble_content', width:150, align:"left"},
		{header:'${text('通知单状态')}', name:'noticeStatus', index:'a.notice_status', width:150, align:"left"},
		{header:'${text('故障级别')}', name:'troubleLevel', index:'a.trouble_level', width:150, align:"left"},
		<!--{header:'${text('状态')}', name:'status', index:'a.status', width:150, align:"center", formatter: function(val, obj, row, act){-->
			<!--return js.getDictLabel(${@DictUtils.getDictListJson('sys_search_status')}, val, '${text('未知')}', true);-->
		<!--}},-->
		//{header:'${text('创建时间')}', name:'createDate', index:'a.create_date', width:150, align:"center"},
		{header:'${text('备注信息')}', name:'remarks', index:'a.remarks', width:150, align:"left"},
		{header:'${text('操作')}', name:'actions', width:120, sortable:false, title:false, formatter: function(val, obj, row, act){
			var actions = [];
			<% if(hasPermi('test:troubleNotice:edit')){ %>
				 if(row.noticeStatus == '已指派，待承接' || row.noticeStatus == '已承接'){
					<%if(hasPermi('test:troubleNotice:view')){%>
                        actions.push('<a href="${ctx}/test/troubleNotice/form?noticeCode='+row.noticeCode+'&planCode='+row.planCode+'&opera=view" class="btnList" title="${text('查看通知单信息')}"><i class="fa fa-eye"></i></a>&nbsp;');
					<% } %>
			    }else{
			    	actions.push('<a href="${ctx}/test/troubleNotice/form?noticeCode='+row.noticeCode+'&planCode='+row.planCode+'" class="btnList" title="${text('编辑故障通知单')}"><i class="fa fa-pencil"></i></a>&nbsp;');
					<!--if (row.status == Global.STATUS_NORMAL){-->
						<!--actions.push('<a href="${ctx}/test/troubleNotice/disable?noticeCode='+row.noticeCode+'" class="btnList" title="${text('停用故障通知单')}" data-confirm="${text('确认要停用该故障通知单吗？')}"><i class="glyphicon glyphicon-ban-circle"></i></a>&nbsp;');-->
					<!--}-->
					<!--if (row.status == Global.STATUS_DISABLE){-->
						<!--actions.push('<a href="${ctx}/test/troubleNotice/enable?noticeCode='+row.noticeCode+'" class="btnList" title="${text('启用故障通知单')}" data-confirm="${text('确认要启用该故障通知单吗？')}"><i class="glyphicon glyphicon-ok-circle"></i></a>&nbsp;');-->
					<!--}-->
					actions.push('<a href="${ctx}/test/troubleNotice/delete?noticeCode='+row.noticeCode+'" class="btnList" title="${text('删除故障通知单')}" data-confirm="${text('确认要删除该故障通知单吗？')}"><i class="fa fa-trash-o"></i></a>&nbsp;');
				}
			<% } %>
			<!--<维修人员只能查看故障通知单，并决定是否承接>-->
			<%if(hasPermi('test:troubleNotice:scan')){%>
            	actions.push('<a href="${ctx}/test/troubleNotice/form?noticeCode='+row.noticeCode+'&planCode='+row.planCode+'&opera=view" class="btnList" title="${text('查看通知单信息')}"><i class="fa fa-eye"></i></a>&nbsp;');
			<% } %>
			return actions.join('');
		}}
	],
	// 加载成功后执行事件
	ajaxSuccess: function(data){
		
	}
});
</script>